<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<style></style>
	<body>
	</body>
	<script>
		// new Date(arrayobj[i].dataTime.replace(/-/g, "/"));
		let list = [{
				createTime: "2022-06-07 15:58:41",
				dataTime: "2022-06-07 15:58:40",
				dataType: 1,
				flag: 2,
				objectNo: "180404",
				sourceFlag: 0,
				speed: null,
				stationDirection: 1,
				stationDistance: 65,
				stationName: "副平硐井口主站",
				stationNo: "107",
				tunnelLoc: 45,
				tunnelName: "副平硐",
				tunnelNo: "5202",
			},
			{
				createTime: "2022-06-07 15:58:16",
				dataTime: "2022-06-07 10:58:15",
				dataType: 1,
				flag: 1,
				objectNo: "180404",
				sourceFlag: 0,
				speed: null,
				stationDirection: 1,
				stationDistance: 10,
				stationName: "副平硐井口主站",
				stationNo: "107",
				tunnelLoc: 100,
				tunnelName: "副平硐",
				tunnelNo: "5202",
			}, {
				createTime: "2022-06-07 15:57:29",
				dataTime: "2022-06-08 16:57:29",
				dataType: 1,
				flag: 1,
				objectNo: "180404",
				sourceFlag: 0,
				speed: null,
				stationDirection: 1,
				stationDistance: 5,
				stationName: "副平硐井口主站",
				stationNo: "107",
				tunnelLoc: 105,
				tunnelName: "副平硐",
				tunnelNo: "5202",
			}
		];
		// console.log(list)
		//返回值最小的对象
		function get_min_obj(arrayobj, type) {
			var mini = 0;
			for (let i = 0; i < arrayobj.length; i++) {
				if (new Date(arrayobj[mini].dataTime.replace(/-/g, "/")) >= new Date(arrayobj[i].dataTime.replace(/-/g,
						"/"))) {
					mini = i;
				}
			}
			return arrayobj[mini];
		}
		console.log('最小', get_min_obj(list))


		//返回值最大的对象
		function get_max_obj(arrayobj, type) {
			var maxi = 0;
			for (let i = 0; i < arrayobj.length; i++) {
				if (new Date(arrayobj[maxi].dataTime.replace(/-/g, "/")) <= new Date(arrayobj[i].dataTime.replace(/-/g,
						"/"))) {
					maxi = i;
				}
			}
			return arrayobj[maxi];
		}

		// 
		// function get_max_obj(arrayobj, type) {
		// 	var maxi = 0;
		// 	for (let i = 0; i < arrayobj.length; i++) {
		// 		if (arrayobj[maxi].id <= arrayobj[i].id) {
		// 			maxi = i;
		// 		}
		// 	}
		// 	return arrayobj[maxi];
		// 	get_max_obj(list) // {id: 3, name: "王五"}
		// }

		console.log('最大', get_max_obj(list))


		// console.log(
		// 	Math.max.apply(
		// 		Math,
		// 		outStationItem.map((item) => {
		// 			return new Date(item.dataTime.replace(/-/g, "/"));
		// 		})
		// 	)
		// );
	</script>
</html>
